package net.wanho.service.impl;

import net.wanho.dao.UserDao;
import net.wanho.exception.UserExistsException;
import net.wanho.po.Account;
import net.wanho.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * Author：汤小洋
 * Date：2025-09-15 10:58
 * Description：<描述>
 */
// @Component  // 由Spring来创建并管理该对象，称为组件Component或Bean
@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Autowired
    private UserDao userDao2;

    @Override
    public void login() {
        System.out.println("处理用户登录业务----------------------------");
        // System.out.println(userDao == userDao2);
        userDao.selectUser();
    }

    @Override
    public void register(Account account) {
        System.out.println("处理用户注册业务----------------------------");

        /**
         * 判断用户名是否存在
         */
        if (account.getUsername().equals("admin")){
            throw new UserExistsException("用户名已存在");
        }

        /**
         * 添加用户到数据库
         */

    }


}
